#!/bin/bash
# filename: reader.sh
# 逐行读取管道中的内容

pipe=/tmp/testpipe

trap "rm -f $pipe" EXIT

if [[ ! -p $pipe ]]; then
    mkfifo $pipe
fi

while true
do
    if read line <$pipe; then
        if [[ "$line" == 'quit' ]]; then
            break
       	else
            echo $line   
		fi
 
    fi
done

echo "Stop reader...."